package com.liu.usky.rlzp.uskyrlzp.service.impl;

import com.liu.usky.rlzp.uskyrlzp.entity.User;
import com.liu.usky.rlzp.uskyrlzp.mapper.UserMapper;
import com.liu.usky.rlzp.uskyrlzp.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户 服务实现类
 * </p>
 *
 * @author lcjzl
 * @since 2020-01-10
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
	@Override
	public User getByAccount(String username) {
		// TODO Auto-generated method stub
		QueryWrapper<User> userw = new QueryWrapper<>();
		userw.lambda().or(oo -> oo.eq(User::getAccount, username))
		.or(oo -> oo.eq(User::getTelephone, username))
		.or(oo -> oo.eq(User::getEmail, username));
		List<User> list = list(userw);
		return list.size()<1?null:list.get(0);
	}

}
